<template>
	<view class="">
		<!-- 跳转页面组件 -->
		<view @click="goPage()">
			<slot></slot>
		</view>
		<login-pop ref="lPop"></login-pop>
	</view>	
</template>

<script>
	const app = getApp();
	import loginPop from '@/components/login-pop/login-pop.vue'

	export default {		
		data() {
			return {
				pageUrls: [
					'/pages/home/index',
					'/pages/goods/goods-commodity-list/index',
					'/pages/earnings/index',
					'/pages/user/user-center/index'
				]
			};
		},
		props: {
			pageUrl: {
				type: String | null,
				default: ''
			}
		},
		components:{
			loginPop
		},
		methods: {
			goPage() {
				if (this.pageUrl && this.pageUrl != "") {
					app.checkLogin().then(res=>{
						if(this.pageUrl=='1'){
							uni.showModal({
								title: '提示',
								content: '功能暂未开通，敬请期待',
								showCancel:false,
								success(res) {}
							});
						} else if (this.pageUrls.indexOf(this.pageUrl) != -1) {
							uni.switchTab({
								url: this.pageUrl
							});
						} else {
							uni.navigateTo({
								url: this.pageUrl
							});
						}
					}).catch(()=>{
						this.$refs.lPop.open()
					})					
					
				}
			}
		}
	}
</script>

<style scoped lang="scss">

</style>